//定义个变量
var a = "jiangxi"
var b = "jiujiang"

//定义变量=数值
var a1 = 1
let a2 = 2

//定义变量=布尔类型
var flag1 = true;
let flag2 = false;

//定义空对象 引用类型
var obj1 = {}
let obj2 = {}

//定义空对象
var obj3 = new Object()
let obj4 = new Object()

//定义空对象并且给空对象增加属性：{属性名："属性值",}
var student = {
    username:"zhangsan",
    passward:"123456",
    gender:"male",
    age:21,
    flag:true,
}
console.log(student.username);//输出统计结果
console.log(student.age);


//给student对象增加地址属性
student.address="jiangxi jiujiang"
console.log(student.address);//输出统计结果

//定义空对象并且给Obj5增加属性
let obj5=new Object()
obj5.appName="微信";
obj5.appPrice=50;
obj5.appAuthor="李四";
obj5.appstatus=true;
console.log(obj5.appPrice);//输出统计结果

//定义一个普通函数
function addPerson(){

}

//定义/声明/设计普通函数  形参为a，b
function calc(a,b){
    console.log(a + b);
}

//运行函数/函数执行/函数调用  3，4为实参
calc(3,4)

//定义普通函数 使用默认值
function printLog(a,b,c=3){
    console.log(a+b+c);
}

//调用
printLog(1,2,4)

//定义普通函数，有返回值
function getNumer(){
    return 2;
}
console.log(getNumer());

//定义普通函数  function + 函数名 +（形参）{}
function getValue(a,b){
    return a + b;
}
console.log(getValue(1,2));

//定义对象 userName 属性名 阿哥score
var personInfor={
    username:"zhangsan",
    age:19,
    score:[80,85,88]
}
function getSum(o){
    let sum = 0
    for (let index = 0; index < o.score.length; index++) {
        sum = sum + o.score[index];
    }
    return sum;
}
console.log(getSum(personInfor));


//升级我的对象
var fruitObj ={
    fruitName:"赣南脐橙",
    fruitPrice:299,
    fruitColor:["red","blue","yellow"],
    price:function getPrice(){
        return this.fruitPrice
    },//this指向当前对象
    colorCount:function getColorCount(){
        return this.fruitColor.length;
    }
}
console.log(fruitObj.price());

//普通函数
function getFruitInfor(){
    return 2+2
}

//匿名函数
 let fruit1 = function(){
    return 2+2
}
fruit1()

//箭头函数
let fruit2 = () => {
    return 2+2;
}
fruit2()

let fruit3 = (a) => {//a为形参
    console.log(a.username);
}
//fruit3(3)//3为实参
fruit3({username:"zhangsan"})

let fruit4 = (b) => {
    b()
}
fruit4(function (){
    console.log("this is fruit4")
})